<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/m/include/init_mobile.jsp" %>
<%
	String nextURL = StringUtil.nvl(request.getParameter("next_url"), "/m/member/");
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/m/include/cssnjs.jsp"  %>
	<link rel="stylesheet" href="/css/jquery.mobile-1.4.2.min.css"/>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#header-nav li:nth-child(4)').addClass('on');
		
		$('.icon-delete').on('click', function() {
			$(this).closest('div').find('input').val('').focus();
			$('.error_message').text('');	
		});
	});
	
	function fnRegist() {

		if (document.frm.member_id.value == "") {
			document.frm.member_id.focus();
			$('.error_message').text('이메일을 입력하세요');
			return false;
		}

		if (document.frm.member_name.value == "") {
			document.frm.member_name.focus();
			$('.error_message').text('성명을 입력하세요');
			return false;
		}

		if (document.frm.member_pw.value == "") {
			document.frm.member_pw.focus();
			$('.error_message').text('비밀번호를 입력하세요');
			return false;
		}
		
		if (document.frm.member_pw.value.length < 4) {
			document.frm.member_pw.focus();
			$('.error_message').text('비밀번호는 4~20글자로 입력하세요');
			return false;
		}
		
		$('.error_message').text('');
		
		$.ajax({
			url: '/member/memberRegist.do',
			type: "POST",
		    dataType: 'json',
		    data:$('#frm').serialize(),
		    error: function(data, status, err){
		    	alert(err);
		    },
			success: function(data){
				if (data.result) {
					document.location.href = "./memberRegistSuccess.jsp?os=<%=os%>&member_id=" + document.frm.member_id.value;
				} else {
					$('.error_message').text('');
				}
		    }
		});
		
		return false;
	}
	
	function fnGoUseTerms() {
		document.location.href = "./useTerms.jsp?os=<%=os%>";
	}
	
	function fnGoPrivacy() {
		document.location.href = "./privacy.jsp?os=<%=os%>";
	}
	</script>
</head>
<body>
	<div id="wrap">
		<%@ include file="/m/include/header.jsp"  %>
		<div id="contents" class="ui-page-theme-a">
			<h2>회원가입</h2>
			<div id="login">
		     	<div class="error_message"></div>
            	<form name="frm" id="frm" method="get" action="" onsubmit="return fnRegist()">
	        		<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear">
		        		<input type="text" name="member_id" value="" maxlength="255" placeholder="이메일"/>
		        		<a href="#" class="ui-input-clear ui-btn icon-delete  ui-corner-all" ></a>
		        	</div>
		        	<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear">
		        		<input type="text" name="member_name" value="" maxlength="255" placeholder="성명"/>
		        		<a href="#" class="ui-input-clear ui-btn icon-delete  ui-corner-all" ></a>
		        	</div>
		        	<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear">
		        		<input type="password" name="member_pw" value="" maxlength="20" placeholder="비밀번호(4~20글자)"/>
		        		<a href="#" class="ui-input-clear ui-btn icon-delete ui-corner-all" ></a>
		        	</div>
		        	<div class="ui-controlgroup-controls">
						<input type="button" class="ui-btn ui-btn-inline" style="width:49%" onclick="fnGoUseTerms()" value="이용약관"/>
						<input type="button" class="ui-btn ui-btn-inline right" style="width:49%" onclick="fnGoPrivacy()" value="개인정보취급방침"/>
					</div>
		        	<div class="ui-btn ui-input-btn ui-btn-active ui-corner-all ui-shadow">
						가입하기<input type="image" alt="가입하기" value="가입하기"/>
					</div>
        		</form>
			</div>
		</div>
		<%@ include file="/m/include/footer.jsp"  %>			
	</div>

</body>

</html>









